home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE23 / STARTUP / StubDll32.dpr < prev    next >
Text File  |  1997-04-27  |  1KB  |  42 lines

  1. library StubDll32;
  2. {$ifndef WIN32}
  3.    'This needs Delphi 32'
  4. {$endif}
  5.  
  6. uses
  7.   Windows,
  8.   SysUtils,
  9.   StubDll32U in 'StubDll32U.pas';
  10.  
  11. { Note that dll_Thread_Detach uses WriteConsole instead of WriteLn }
  12. { This is because WriteLn mysteriously crashes the program if used there }
  13. procedure DLLEntryPoint(dwReason: DWord);
  14. const
  15.   DetachText: String = 'DLL: DLLEntryPoint(dll_Thread_Detach)'#13#10;
  16. var
  17.   CharsWritten: DWord;
  18. begin
  19.   case dwReason of
  20.     dll_Process_Attach:
  21.       WriteLn('DLL: DLLEntryPoint(dll_Process_Attach)');
  22.     dll_Thread_Attach:
  23.       WriteLn('DLL: DLLEntryPoint(dll_Thread_Attach)');
  24.     dll_Thread_Detach:
  25.       WriteConsole(TTextRec(Output).Handle, PChar(DetachText),
  26.         Length(DetachText), CharsWritten, nil);
  27.     dll_Process_Detach:
  28.       WriteLn('DLL: DLLEntryPoint(dll_Process_Detach)');
  29.   end;
  30. end;
  31.  
  32. begin
  33.   WriteLn('DLL: Main program block');
  34.   if IsLibrary then  
  35.   begin
  36.     // Set up the DLLEntryPoint routine
  37.     DllProc := @DLLEntryPoint;
  38.     // Call it for process attachment (it won't happen automatically)
  39.     DLLEntryPoint(dll_Process_Attach);
  40.   end;
  41. end.
  42.